package com.jxwifi.cloud.quickclean.popwindow;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.idroid.utils.NoDoubleClickListener;
import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.app.StateUtils;
import com.popwindow.BasicPopmodule;

public class PopSexModule extends BasicPopmodule {

    private Context mContext;
    private PopSexListener mPoplistener;

    public PopSexModule(Context context, PopSexListener l) {
        this.mContext = context;
        this.mPoplistener = l;
        initView();
    }

    @Override
    public void setPopwindow(PopupWindow pop) {
        mPopwindows = pop;
    }

    @Override
    public View getView() {
        return mContentView;
    }

    private void initView() {
        mContentView = LayoutInflater.from(mContext).inflate(R.layout.pop_show_sex_module, new LinearLayout(mContext), false);
        setListener();
    }

    private void setListener() {
        View mVwPopBlan = (View) mContentView.findViewById(R.id.vw_pop_blank);
        TextView mTvSexMan = (TextView) mContentView.findViewById(R.id.tv_pop_sex_man);
        TextView mRvSexWoman=(TextView)mContentView.findViewById(R.id.tv_pop_sex_woman);
        mVwPopBlan.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPopwindows.dismiss();
            }
        });
        mTvSexMan.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPoplistener.SexMan(StateUtils.SEX_M);
                mPopwindows.dismiss();
            }
        });
        mRvSexWoman.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                mPoplistener.SexWoman(StateUtils.SEX_W);
                mPopwindows.dismiss();
            }
        });
    }

    public interface PopSexListener {
        void SexMan(String sexType);

        void SexWoman(String sexType);
    }
}
